﻿@{
    ViewBag.Title = "保养计划明细";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section scripts{
    <script src="~/Areas/Dev/ViewModels/Dev.com.js"></script>
    <script src="~/Areas/Dev/ViewModels/Dev.viewModel.edit.js"></script>
    <script type="text/javascript">
            using(['numberbox','lookup','combobox']);
            var viewModel = function(){
                var self = this;
                Dev.viewModel.edit.apply(self,arguments);
                this.grid.size={w:6,h:151};
                 this.saveClick = function () {
                    //保存主表及明细表
                    var bmmc=$("#Byjh_Bzry").combobox('getText');
                    self.form["Byjh_Bzry"]=bmmc;
                    //
                    this.saveClick_Two();

                    };
                this.addRowClick = function(){
                        if (self.readonly()) return;
                        var sBillNo = this.scrollKeys.current();
                        //获取RowId 与单据编号
                        com.ajax({
                            type: 'GET',
                            url: this.urls.getrowid + 1,
                            data: { BillNo: sBillNo },
                            success: function (d) {
                                var row = $.extend({ Byjhmx_BillNo: sBillNo, Byjhmx_Flbh: d }, self.defaultRow);
                               // var row = { Byjlmx_BillNo: sBillNo, Byjlmx_Flbh: d };
                                self.gridEdit.addnew(row);
                            }
                        });
              };  
              this.grid.OnBeforeDestroyEditor = function (editors, row) {
                    row.Byjhmx_Byxm = editors["Byjhmx_Byxm"].target.lookup('textbox').val();
              };
    };
    var data = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model));
    ko.bindingViewModel(new viewModel(data));


    //格式化checkbox true false
      frmatCheckboxs = function (value) {
                var checked = (value || 'false').toString() == 'passed';
                return utils.formatString('<img value={0} src="/Content/images/{1}"/>', checked, checked ? "checkmark.gif" : "checknomark.gif");
      };
    </script>
}

<div class="z-toolbar">
        <a id="a_save" href="#" plain="true" class="easyui-linkbutton" icon="icon-save" data-bind="click:saveClick,linkbuttonDisable:readonly" title="保存">保存</a>
        <a id="a_undo" href="#" plain="true" class="easyui-linkbutton" icon="icon-undo" data-bind="click:rejectClick,linkbuttonDisable:readonly" title="撤消">撤消</a>
        <a id="a_audit" href="#" plain="true" class="easyui-linkbutton" icon="icon-user-accept" data-bind="click:auditClick,easyuiLinkbutton:approveButton" title="审核">审核</a>
        <a id="a_printer" href="#" plain="true" class="easyui-linkbutton" icon="icon-printer" title="打印" data-bind="click:printClick">打印</a>
        <div class="datagrid-btn-separator"></div>
        <a id="a_first" href="#" plain="true" class="easyui-linkbutton" icon="icon-resultset_first" data-bind="click:firstClick,linkbuttonEnable:scrollKeys.firstEnable" title="第一条"></a> 
        <a id="a_previous" href="#" plain="true" class="easyui-linkbutton" icon="icon-resultset_previous" data-bind="click:previousClick,linkbuttonEnable:scrollKeys.previousEnable" title="上一条"></a> 
        <a id="a_next" href="#" plain="true" class="easyui-linkbutton" icon="icon-resultset_next" data-bind="click:nextClick,linkbuttonEnable:scrollKeys.nextEnable" title="下一条"></a> 
        <a id="a_last" href="#" plain="true" class="easyui-linkbutton" icon="icon-resultset_last" data-bind="click:lastClick,linkbuttonEnable:scrollKeys.lastEnable" title="最后一条"></a> 
    </div>


   <div id="master" class="container_12" data-bind="inputwidth:0.9">
        <div class="grid_1 lbl">计划编号</div>
        <div class="grid_3 val"><input type="text"  data-bind="value:form.Byjh_BillNo,readOnly:readonly" class="z-txt readonly" disabled="disabled" /></div>
        <div class="grid_1 lbl">设备编号</div>
        <div class="grid_3 val"><input type="text"  data-bind="lookupValue:form.Byjh_Sbbh,lookupReadOnly:readonly"  required="true" class="z-txt easyui-lookup" data-options="lookupType:'sbda',parentField:'pid',multiple:false"/></div>
        <div class="grid_1 lbl required">计划日期</div>
        <div class="grid_3 val"><input type="text"  data-bind="dateboxValue:form.Byjh_Ywrq,readOnly:readonly"  class="z-txt easyui-datebox" /></div>
        <div class="clear"></div>

        <div class="grid_1 lbl required">部门编号</div>
        <div class="grid_3 val"><input type="text"  data-bind="lookupValue:form.Byjh_Bmbh,lookupReadOnly:readonly" required="true" class="z-txt easyui-lookup" data-options="lookupType:'organize',multiple:false"/></div>
        <div class="grid_1 lbl">编制人员</div>
        <div class="grid_3 val required">
            <input type="text" id="Byjh_Bzry" data-bind="lookupValue:form.Byjh_Bzry,lookupReadOnly:readonly"  required="true"  class="z-txt easyui-lookup" data-options="lookupType:'sysuser',multiple:true" />
        </div>
        <div class="grid_1 lbl">最近保养</div>
        <div class="grid_3 val"><input type="text"  data-bind="dateboxValue:form.Byjh_Zjbysj,readOnly:readonly" class="z-txt easyui-datebox"/></div>
        <div class="clear"></div>

        <div class="grid_1 lbl required">开始日期</div>
        <div class="grid_3 val"><input type="text" data-bind="dateboxValue:form.Byjh_Kssj,readOnly:readonly" class="z-txt easyui-datebox"  /></div>
        <div class="grid_1 lbl required">结束日期</div>
        <div class="grid_3 val"><input type="text" data-bind="dateboxValue:form.Byjh_Jssj,readOnly:readonly" class="z-txt easyui-datebox" /></div>
        <div class="grid_1 lbl required">保养周期</div>
        <div class="grid_3 val"><input type="text" data-bind="numberboxValue:form.Byjh_Byzq,readOnly:readonly" class="z-txt easyui-numberbox"  /></div>
        <div class="clear"></div>

        <div class="grid_1 lbl">单据来源</div>
        <div class="grid_3 val"><input type="text" data-bind="value:form.Byjh_Djly,readOnly:readonly" class="z-txt"  /></div>
        <div class="grid_1 lbl">备注说明</div>
        <div class="grid_7 val required"><input type="text" data-bind="value:form.Byjh_Remark,readOnly:readonly" class="z-txt"  /></div>
        <div class="clear"></div>
    </div>
  
    <div id="tt" class="easyui-tabs">  
        <div title="表单明细">
            <table id="list" data-bind="datagrid:grid">
                <thead>
                    <tr>
                        <th field="Byjhmx_BillNo" hidden="true"></th>  
                        <th field="Byjhmx_Flbh"   hidden="false"  >分录编号</th> 
                        <th field="Byjhmx_Bybw"   align="left"   width="90"  editor="text" >保养部位</th>  
                        <th field="Byjhmx_Byxm"   align="left"   width="140"  editor="{type:'lookup',options:{lookupType:'sbbyxm',parentField:'pid'}}" >保养项目</th>  
                        <th field="Byjhmx_Bynr"   align="left"   width="300"  editor="text" >保养内容</th>  
                        <th field="Byjhmx_Fzry" align="left"   width="80" editor="text" >负责人员</th> 
                        <th field="Byjhmx_Jcry"   align="left"   width="80"  editor="text" >检查人员</th>
                        <th field="Byjhmx_Remark" align="left"   width="320" editor="text" >备注</th>   
                        <th field="CreatePerson" align="left"   width="80"  >创建人</th>  
                        <th field="CreateDate" align="left"   width="90"  formatter="com.formatDate" >创建日期</th>  
                        
                    </tr>
                </thead>
            </table>  
            
            <div id="gridtb">
                <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" data-bind="click:addRowClick,linkbuttonDisable:readonly">增加明细</a>
                <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" data-bind="click:removeRowClick,linkbuttonDisable:readonly">删除明细</a>
            </div>  
        </div>
        <div title="表单信息" class="hide" style="padding-top:2px;">
            <div class="container_12" id="BillDetail" data-bind="inputwidth:0.9,autoheight:181"> 
                <div class="clear"></div>
                
                <div class="grid_1 lbl">编制人</div>
                <div class="grid_3 val "><input type="text" id="CreatePerson" data-bind="value:form.CreatePerson,readOnly:true" class="z-txt readonly" /></div>
                <div class="grid_1 lbl">编制日期</div>
                <div class="grid_3 val"><input type="text" id="CreateDate" data-bind="dateboxValue:form.CreateDate,dateboxReadOnly:true" class="z-txt easyui-datebox readonly" /></div>
                <div class="grid_1 lbl">审批状态</div>
                <div class="grid_3 val"><input type="text" id="ApproveState" data-bind="value:form.ApproveState,readOnly:true"  class="z-txt readonly"/></div>
                <div class="clear"></div>

                <div class="grid_1 lbl">修改人</div>
                <div class="grid_3 val "><input type="text" id="UpdatePerson" data-bind="value:form.UpdatePerson,readOnly:true" class="z-txt readonly" /></div>
                <div class="grid_1 lbl">修改日期</div>
                <div class="grid_3 val"><input type="text" id="UpdateDate" data-bind="dateboxValue:form.UpdateDate,dateboxReadOnly:true" class="z-txt easyui-datebox readonly" /></div>
                <div class="clear"></div>

                <div class="grid_1 lbl">审批人</div>
                <div class="grid_3 val"><input type="text" id="ApprovePerson"data-bind="value:form.ApprovePerson,readOnly:true" class="z-txt readonly"/></div>
                <div class="grid_1 lbl">审批日期</div>
                <div class="grid_3 val"><input type="text" id="ApproveDate" data-bind="dateboxValue:form.ApproveDate,dateboxReadOnly:true"  class="z-txt easyui-datebox readonly"/></div>
                <div class="clear"></div>

                <div class="grid_1 lbl">审批意见</div>
                <div class="grid_7 val"><input type="text" id="ApproveRemark" data-bind="value:form.ApproveRemark,readOnly:true"  class="z-txt readonly"/></div>

            </div>
        </div> 
    </div>  